#include <iostream>
#include <future>
#include <chrono>
#include <thread>

int Add(int a, int b)
{
    // std::this_thread::sleep_for(std::chrono::seconds(5));
    std::cout << "Add..." << std::endl;
    return a + b;
}

int main()
{
    // std::launch::async std::launch::deferred
    std::cout << "----------1---------------" << std::endl;
    std::future<int> result = std::async(std::launch::async, Add, 1, 2);
    // std::future<int> result = std::async(std::launch::deferred, Add, 1, 2);
    std::this_thread::sleep_for(std::chrono::seconds(1));
    std::cout << "----------2---------------" << std::endl;
    int sum = result.get();
    std::cout << "---------3---------------" << std::endl;
    std::cout << sum << std::endl;
    return 0;
}